package com.le.tester.tip;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;

import java.util.concurrent.ThreadLocalRandom;

/**
 * createTime：2023/11/30 14:54
 * description：使用雪花算法随机生成唯一订单号
 */
public class RandomSnowFlake {
    public static void main(String[] args) {

        for (int i = 0; i < 1000; i++) {
            long start = ThreadLocalRandom.current().nextLong(0, 30);
            long end = ThreadLocalRandom.current().nextLong(0, 30);

            Snowflake snowflake = IdUtil.getSnowflake(start, end);
            String result = snowflake.nextIdStr();
            System.out.println(result);
        }
//        for (int i = 0; i < 100; i++) {
//            int start = ThreadLocalRandom.current().nextInt(10);
//            int end = ThreadLocalRandom.current().nextInt(1024);
//            String result = String.valueOf(NumberUtil.generateRandomNumber(start, end, 1)[0]);
//            System.out.println(result);
//        }
    }


}
